package com.spzx.order;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.core.web.domain.BaseEntity;

public class GenMP {

    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://192.168.159.100:3306/spzx-order ?characterEncoding=utf-8&useSSL=false", "root", "root")
                .globalConfig(builder -> builder
                        .author("lynn")
                        .outputDir("D:\\CodeSpace\\spzx-parent\\spzx-modules\\spzx-order\\src\\main\\java")
                        .dateType(DateType.ONLY_DATE) //定义代码生成日期类型为java.util.Date 默认为java.sql.Date
                        .disableOpenDir()  //禁止打开输出目录
                )
                .packageConfig(builder -> builder
                        .parent("com.spzx.order")
                        .entity("domain")
                        .mapper("mapper")
                        .xml("mapper.order")
                        .service("service")
                        .serviceImpl("service.impl")
                        .controller("controller")
                )
                .strategyConfig(builder -> builder
                        .addInclude(
                                "order_info",
                                "order_item",
                                "order_log") // 设置需要生成的表名

                        .entityBuilder()
                        .enableLombok()
                        .superClass(BaseEntity.class)
                        .addSuperEntityColumns(
                                "id",
                                "create_by",
                                "create_time",
                                "update_by",
                                "update_time",
                                "remark",
                                "del_flag")
                        //.addIgnoreColumns //忽略字段
                        .enableFileOverride() //覆盖已生成文件

                        .serviceBuilder()
                        .formatServiceFileName("%sService")
                        .enableFileOverride()

                        .controllerBuilder()
                        .superClass(BaseController.class)
                        .enableRestStyle()
                        .enableFileOverride()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}